package Views;

import Dao.OnePara;

import java.util.Scanner;

/**
 * 执行学生信息操作
 * @author 李宝瑞
 *
 */
public class StudentView {
    private OnePara onePara;
    private MainPage mainPage = new MainPage();

    public void mainView() {
        onePara = new OnePara();
        Scanner input = new Scanner(System.in);
        boolean con = false;
        do {
            System.out.println("执行学生信息操作");
            System.out.println("****************************************");
            System.out.println("\n\t\t1.添加学生信息\n");
            System.out.println("\t\t2.更改学生信息\n");
            System.out.println("\t\t3.删除学生信息\n");
            System.out.println("****************************************");
            System.out.println("请选择,输入数字或者按0返回上一级菜单：");

            int num = input.nextInt();
            switch (num) {
                case 0:
                    mainPage.mainMenu();
                    break;
                case 1:
                    //逻辑复杂，单独成类
                    AddStuInfoView addStuInfoView = new AddStuInfoView();
                    addStuInfoView.mainView();
                    con = true;
                    break;
                case 2:
                    //同上
                    UpdateStuInfoView updateStuInfoView = new UpdateStuInfoView();
                    updateStuInfoView.mainView();
                    con = true;
                    break;

                case 3:
                    String flag3 = "";
                    do {
                        System.out.println("请输入要删除的学生姓名：");
                        String delStuName = input.next();
                        onePara.deleteStudent(delStuName);
                        System.out.println("是否继续，y or n");
                        flag3 = input.next();
                    } while ("y".equals(flag3));
                    con = true;
                    break;
            }
        } while (con);
    }
}
